package com.cloudfunx.common.constant;

/**
 * 锁标志，用来提供一定的幂等性
 */
public class LockConst {

    /**
     * 防止用户重复付款锁
     * TAKE_ORDER: + USERID
     */
    public static final String TAKE_ORDER_LOCK = "TAKE_ORDER_LOCK:";

    /**
     * 订单状态修改锁
     * ORDER_STATUS_LOCK: + orderNO
     */
    public static final String ORDER_STATUS_LOCK = "ORDER_STATUS_LOCK:";

    /**
     * 订单退款乐观锁
     * ORDER_REFUND_LOCK: + orderNO
     */
    public static final String ORDER_REFUND_LOCK = "ORDER_REFUND_LOCK:";

    /**
     * 定时任务中：审查订单状态的锁 集群时，一台执行就够了
     * SCHEDULED_ORDER_STATUS_CHECK_LOCK
     */
    public static final String SCHEDULED_ORDER_STATUS_CHECK_LOCK = "SCHEDULED_ORDER_STATUS_CHECK_LOCK";

    /**
     * 管理员发布乐观锁
     * PUBLISH_LOCK: + recycleInformationId
     */
    public static final String PUBLISH_LOCK = "PUBLISH_LOCK:";

    public static String generatePublishLock(Long recycleInformationId) {
        return PUBLISH_LOCK + recycleInformationId;
    }
}
